<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<c:if test="${requestScope.page.pageNo != 1}">
    <div>
        <a href="${requestScope.page.path}&pageNo=1">首页</a>
    </div>
    <div>
        <a href="${requestScope.page.path}&pageNo=${requestScope.page.pageNo-1}">上一页</a>
    </div>
</c:if>
<c:choose>
    <c:when test="${requestScope.page.totalPage<5}">
        <c:set var="begin" value="1"></c:set>
        <c:set var="end" value="${requestScope.page.totalPage}"></c:set>
    </c:when>
    <c:when test="${requestScope.page.pageNo<3}">
        <c:set var="begin" value="1"></c:set>
        <c:set var="end" value="5"></c:set>
    </c:when>
    <c:otherwise>
        <c:set var="begin" value="${requestScope.page.pageNo-2}"></c:set>
        <c:set var="end" value="${requestScope.page.pageNo+2}"></c:set>
        <c:if test="${pageScope.end>requestScope.page.totalPage}">
            <c:set var="begin" value="${requestScope.page.totalPage-4}"></c:set>
            <c:set var="end" value="${requestScope.page.totalPage}"></c:set>
        </c:if>
    </c:otherwise>
</c:choose>
<ul>
    <c:forEach begin="${pageScope.begin}" end="${pageScope.end}" var="num">
        <c:if test="${requestScope.page.pageNo == pageScope.num}">
            <li class="active">
                <a href="${requestScope.page.path}&pageNo=${pageScope.num}">${pageScope.num}</a>
            </li>
        </c:if>
        <c:if test="${requestScope.page.pageNo != pageScope.num}">
            <li>
                <a href="${requestScope.page.path}&pageNo=${pageScope.num}">${pageScope.num}</a>
            </li>
        </c:if>
    </c:forEach>
</ul>
<c:if test="${requestScope.page.pageNo != requestScope.page.totalPage}">
    <div>
        <a href="${requestScope.page.path}&pageNo=${requestScope.page.pageNo+1}">下一页</a>
    </div>
    <div>
        <a href="${requestScope.page.path}&pageNo=${requestScope.page.totalPage}">末页</a>
    </div>
</c:if>
<span>共${requestScope.page.totalPage}页</span>
<span>${requestScope.page.count}条记录</span>
<span>到第</span>
<input type="text" id="pageNo" />
<span>页</span>
<button id="btnId">确定</button>
<script type="text/javascript">
    $(function () {
        $("#btnId").click(function () {
            var pageNo = $("#pageNo").val();
            location = "${requestScope.page.path}&pageNo="+pageNo;
        });
    });
</script>
